# Stage 1: Build the application
FROM maven:3.5-jdk-8-alpine AS builder

# Set the working directory
WORKDIR /app

# Copy the Maven pom.xml and source code
COPY pom.xml .
COPY src ./src

# Build the application
RUN mvn package -DskipTests

# Stage 2: Create the final image
FROM openjdk:8-jre-alpine

# Set the working directory
WORKDIR /app

# Copy the JAR file from the builder stage
COPY --from=builder /app/target/DitingPlatform-backend-0.0.1-SNAPSHOT.jar .

# Run the application
CMD ["java", "-jar", "DitingPlatform-backend-0.0.1-SNAPSHOT.jar", "--spring.profiles.active=prod"]